package com.project.annotation;

import javax.lang.model.element.Element;

public class ARouterBean {


    public enum Type{
        /**
         * activity类型
         */
        ACTIVITY;
    }

    private Type mType;

    /**
     * 类结点
     */
    private Element mElement;
    /**
     * 组名
     */
    private String group;
    /**
     * 路由的地址
     */
    private String path;

    private Class<?> mClazz;


    private ARouterBean() {
    }
    private ARouterBean(Type type, Class<?> clazz, String path, String group) {
        this.mType = type;
        this.mClazz = clazz;
        this.path = path;
        this.group = group;
    }
    public static ARouterBean create(Type type,Class<?> clazz,String path,String group){
        return new ARouterBean(type,clazz,path,group);
    }
    private ARouterBean(Builder builder) {
        mElement = builder.mElement;
        group = builder.group;
        path = builder.path;
    }

    public Type getType() {
        return mType;
    }

    public Element getElement() {
        return mElement;
    }

    public String getGroup() {
        return group;
    }

    public String getPath() {
        return path;
    }

    public Class<?> getClzz() {
        return mClazz;
    }

    public void setType(Type type) {
        mType = type;
    }

    public void setGroup(String group) {
        this.group = group;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public static final class Builder{
        private Element mElement;
        private String group;
        private String path;

        public Builder setElement(Element element) {
            mElement = element;
            return this;
        }

        public Builder setGroup(String group) {
            this.group = group;
            return this;
        }

        public Builder setPath(String path) {
            this.path = path;
            return this;
        }
        public ARouterBean build(){
            if(path==null||path.length()==0){
                throw new IllegalArgumentException("path 为空 比如 /app/MainActivity");
            }
            return new ARouterBean(this);
        }
    }

    @Override
    public String toString() {
        return "ARouterBean{" +
                "group='" + group + '\'' +
                ", path='" + path + '\'' +
                '}';
    }
}
